Skip to main content link. Accesskey S
  • Help
  • HCL Logo
  • HCL Notes and Domino Application Development wiki
  • THIS WIKI IS READ-ONLY. Individual names altered for privacy purposes.
  • HCL Forums and Blogs
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • API Documentation
Search
Community Articles > Troubleshooting > Onblur - runs more than once - is there a fix?
  • Share Show Menu▼
  • Subscribe Show Menu▼

Recent articles by this author

Onblur - runs more than once - is there a fix?

summary I'll use an example to explain.  I have a document that users record to track number of items completed (numItems) and total time (time).  numItems should be an integer and time should be hh:mm.  I have 20 of these on the document and I have totals and other things, but that's beyond the ...

view with multiple rows for a single document

summary  This seems so elementary, but I don't use these very often and it seems like every time I get a little stuck, so I decided it's worth documenting.  This is how to display multiple rows of data from a single Notes document.  I often use this concept when I have a business area that needs a ...

split checkbox field into multiple fields without re-saving all existing docs

Existing field is a multivalue check box.  Let's call this field  cities    Need to split into multiple fields without resaving every document in the database.  Let's call these fields  citiesMN and citiesWI   Step 1:  Hide cities field Step 2:  New fields citiesMN citiesWI are ...
Community articleOnblur - runs more than once - is there a fix?
Added by ~Mark Minretherikle on November 1, 2011 | Version 1
  • Actions Show Menu▼
expanded Abstract
collapsed Abstract
No abstract provided.
, onblur, troubleshooting
summary
I'll use an example to explain.  I have a document that users record to track number of items completed (numItems) and total time (time).  numItems should be an integer and time should be hh:mm.  I have 20 of these on the document and I have totals and other things, but that's beyond the scope of this documentation.  Whenever numItems or time is entered, I want to immediately validate the user input, check to see if the other piece is entered, and compute an average time per item.  This is easy to do with LotusScript in the Onblur event.  But there's a PROBLEM.  Onblur is finicky and tends to run more than once (see Notes help), so I tried to trick it to run only once.
 
option 1:  set a flag on the uidoc or with a global variable
I use Onfocus and a "currentField" field to track the field I'm on.  I set my Onblur flag to "done" the first time Onblur runs.   This works, but Onblur will run exactly once.  This is a problem if I never left the field, but want to do some input validation.
 
option 2:  use timer at the very end of my onBlur code to prevent multiple execution with X/100ths of a second
timer is easy to use and returns a single in time elapsed since midnight to the 100ths of a second.  Again, I can use the uidoc, or a global variable to track and make sure Onblur doesn't run multiple times within say 25/100ths of a second.  This works, but I need to make sure I set the timer at the right time and calculate correctly etc.  The 25/100ths of 1 second that I picked is arbitrary and based on my assumption that a fast data entry user won't be able to update and trigger onBlur this quickly.  This is certainly not a perfect solution.
 
conclusion
It's possible but not clean and simple to make sure Onblur runs only once.  Whenver possible, I try to avoid this type of "in-line" processing and validation using the onBlur event. 

  • Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (1)
collapsed Versions (1)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (1)Nov 1, 2011, 3:59:44 PM~Mark Minretherikle  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedAbout
  • HCL Software
  • HCL Digital Solutions community
  • HCL Software support
  • BlogsDigital Solutions blog
  • Community LinkHCL Software forums and blogs
  • About HCL
  • Privacy
  • Accessibility